Miles Sound System SDK 7.2a

Q:

How do I set a DSP filter on a sample?

A:

To set a DSP filter, you have to first find the filter(s) that you want to apply. To find a filter, you can either enumerate through the possible filters looking for the one you want (using the AIL_enumerate_filters function), or you can use the simple utility function AIL_find_filter. For example, to find the high-pass DSP filter, do something like this:


Register_RIB(DSP); // Needed on non-Win32 DLL platforms such as DOS, Xbox, Wii, PS2 and PS3
AIL_startup();
...
...
...
HPROVIDER high_pass;
if ( AIL_find_filter( "HighPass Filter", &high_pass ) )
{
// success!
}

Once we have a handle to the high-pass filter, we have to apply it to our HSAMPLE with the AIL_set_sample_processor function. Eight filter slots, labelled SP_FILTER_0 through SP_FILTER_7, are available:


// init the sample
AIL_init_sample( S, DIG_F_MONO_16, 0 );


//later, apply the filter
AIL_set_sample_processor( S, SP_FILTER_0, high_pass );

Make sure you call AIL_set_sample_processor after you call AIL_init_sample, AIL_set_sample_file, AIL_set_sample_info, or AIL_set_named_sample_file. Filters may be assigned in any order, and it's OK to skip slots altogether. Filters assigned to lower-numbered slots are executed prior to those in higher-numbered ones.

Now, all that remains is setting the specific filter properties that you'd like to control. To do that, call the AIL_sample_stage_property function with one of the properties described in the Digital Filter Services Section. To finish our example, let's set the high-pass filter to kick in at 4000 Hz, like this:


F32 value=4000.0F;
AIL_sample_stage_property( S, SP_FILTER_0, "Highpass Cutoff", &value, 0, 0 );

Again, in most cases, you should install any DSP filters after declaring an HSAMPLE's format, but before starting playback. Installing or removing a DSP pipeline filter on a playing HSAMPLE may cause audible artifacts. To disable an existing filter's influence on a given HSAMPLE without uninstalling the filter, set the filter's "Mix' preference (if available) to 0.0.

Software DSP filters may be unsuitable for performance-critical applications on the original Xbox; the Xbox has specific dedicated DSP hardware that you may wish to use instead. Software DSP filters on the Xbox cannot be applied to Xbox ADPCM samples or 8-bit PCM samples.

See the FILTER.CPP and MULTIFLT.CPP example programs for more information.

Next Topic (How much CPU do the various filters use?)

Previous Topic (How do I apply a low-pass filter?)


Group: FAQs and How Tos
Related Functions: AIL_enumerate_filters, AIL_find_filter, AIL_init_sample, AIL_sample_stage_property, AIL_set_named_sample_file, AIL_set_sample_file, AIL_set_sample_info, AIL_set_sample_processor

For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.